import {
	CustomViewActionType,
	ICustomViewAbility,
	ICustomViewControllerParams,
	ICustomViewModel,
	ICustomViewStore,
	IParam,
	IViewEvent,
} from '@/core';
import { QXEvent } from 'qx-util';
import {
	getViewClassNames,
	useViewAction,
	useViewBasic,
	useViewControllerParams,
	useViewProps,
} from '../use-view';

/**
 * 获取实体自定义视图输入参数
 *
 * @export
 * @return {*}
 */
export function useCustomViewProps() {
	return {
		...useViewProps(),
	};
}

/**
 * 获取实体自定义视图基础
 *
 * @export
 * @param {ICustomViewModel} model 实体自定义视图模型
 * @param {IParam} props 输入参数
 * @return {*}
 */
export function useCustomViewBasic(model: ICustomViewModel, props: IParam) {
	const getClassNames = (props: IParam) => {
		return getViewClassNames(model, props);
	};
	return {
		...useViewBasic(model, props),
		getClassNames,
	};
}

/**
 * 实体自定义视图行为
 *
 * @export
 */
export function useCustomViewAction(controller: any) {
	return {
		...useViewAction(controller),
	};
}

/**
 * 获取实体自定义视图控制器输入参数
 *
 * @export
 * @param {ICustomViewModel} model
 * @param {IParam} props
 * @param {QXEvent<IViewEvent<CustomViewActionType, ICustomViewAbility>>} evt
 * @return {*}  {ICustomViewControllerParams<CustomViewActionType, ICustomViewAbility>}
 */
export function useCustomViewControllerParams(
	model: ICustomViewModel,
	props: IParam,
	evt: QXEvent<IViewEvent<CustomViewActionType, ICustomViewAbility>>
): ICustomViewControllerParams<CustomViewActionType, ICustomViewAbility> {
	return {
		...useViewControllerParams<ICustomViewStore, ICustomViewModel>(
			model,
			props,
			evt
		),
	};
}
